function fn(arr){   
    return arr.filter((value,index,a)=>{
        return a.indexOf(value,0)==index;
    })
}

console.log(fn([1,2,3,1,2,3,4]));